package com.yangzheandroid.rxmvp.presenter.login;

import com.yangzheandroid.rxmvp.base.RxPresenter;
import com.yangzheandroid.rxmvp.beans.UserBean;
import com.yangzheandroid.rxmvp.http.DefaultSubscriber;
import com.yangzheandroid.rxmvp.http.HttpClients;
import com.yangzheandroid.rxmvp.view.activity.login.ForgetPsdActivity;
import com.yangzheandroid.rxmvp.view.activity.login.ForgetPsdContract;

import javax.inject.Inject;

import rx.Subscription;


public class ForgetPsdPresenter extends RxPresenter<ForgetPsdContract.View> implements ForgetPsdContract.Presenter {
    ForgetPsdActivity mView;
   @Inject
    public ForgetPsdPresenter() {

    }

    @Override
    public void modifyUserPsd() {
//        CommonUtils.getToken( mView, new CallBackStore.TokenCallBack() {
//            @Override
//            public void onSuccess(String token) {
//                forgetPsd(token);
//            }
//
//            @Override
//            public void onFailed() {
//                ToastUtils.showToast("未登录");
//            }
//        });

    }

    /**
     * 忘记密码
     *
     * @param token
     */
    private void forgetPsd(String token) {
        Subscription subscribe = HttpClients.subscribe(HttpClients.apiStore().modifyUserPsd(token, mView.getOldPassword(), mView.getNewPassword()), new DefaultSubscriber<UserBean>() {
            @Override
            public void onNext(UserBean userBean) {
                mView.showMessage("修改密码成功");
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                mView.showMessage("修改密码失败");
            }
        });
        addSubscribe(subscribe);

    }


}
